package com.shouxue.dragrvdemo;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.provider.Settings;

import java.util.ArrayList;
import java.util.List;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {

    DragShortcutView mDragShortcutView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);

        if (!Settings.canDrawOverlays(this)) {
            Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:$packageName"));
            startActivityForResult(intent, 1000);
        }

        mDragShortcutView = findViewById(R.id.drag_shortcut_view);
        mDragShortcutView.setAddOrDeleteListener(new DragShortcutView.AddOrDeleteListener() {
            @Override
            public void usedAddOrDeleteShortcut(int usedSize) {

            }

            @Override
            public void allAddOrDeleteShortcut(int allSize) {

            }
        });
        List<ItemBean> addLists = new ArrayList<>();
        List<ItemBean> notAddLists = new ArrayList<>();
        for (int i = 0; i < 10; i++){
            ItemBean item = new ItemBean(this);
            item.setTitle("a" + i);
            item.setAdded(true);
            addLists.add(item);
        }
        for (int i = 10; i < 22; i++){
            ItemBean item = new ItemBean(this);
            item.setTitle("b" + i);
            item.setAdded(false);
            notAddLists.add(item);
        }
        mDragShortcutView.setData(addLists, notAddLists);
    }
}